import 'package:flutter/material.dart';
import 'package:yuan_hang_app/base/base_state.dart';
import 'package:yuan_hang_app/base/full_base_page.dart';
import 'package:yuan_hang_app/res/w_colors.dart';
import 'package:yuan_hang_app/res/w_dimens.dart';
import 'package:yuan_hang_app/utils/size_utils.dart';
import 'package:yuan_hang_app/widget/label_item.dart';
import 'package:yuan_hang_app/widget/w_line.dart';
import 'package:yuan_hang_app/widget/w_text.dart';

class OrderDetailPage extends StatefulWidget {
  const OrderDetailPage({super.key});

  @override
  BaseState<OrderDetailPage> createState() => _OrderDetailPageState();
}

class _OrderDetailPageState extends BaseState<OrderDetailPage> {
  @override
  FullBasePage buildState(BuildContext context) {
    return FullBasePage(
      title: "订单详情",
      child: ListView(
        padding: EdgeInsets.zero,
        shrinkWrap: true,
        children: [
          _cardItem("订单信息", _orderInfo()),
          _cardItem("客户信息", _customerInfo()),
          _cardItem("车辆明细", _carInfo()),
          _cardItem("其他信息", _otherInfo(), bottom: 10),
        ],
      ),
    );
  }

  Container _cardItem(String label, Widget child, {double bottom = 0}) {
    return Container(
      margin: EdgeInsets.only(
          top: 10.px, left: 15.px, right: 15.px, bottom: bottom.px),
      decoration: BoxDecoration(
          color: Colors.white, borderRadius: BorderRadius.circular(10.px)),
      child: Column(
        crossAxisAlignment: CrossAxisAlignment.start,
        children: [
          Container(
            height: 48.px,
            alignment: Alignment.centerLeft,
           // padding: EdgeInsets.only(left: 15.px),
            child: Row(
              children: [
                WLine(height: 16.px,width: 4.px,color: WColors.primaryColor,marginRight: 15.px,),
                WText(
                  label,
                  style: TextStyle(
                      fontSize: WDimens.tsLarge,
                      color: WColors.mainTextColor,
                      fontWeight: FontWeight.bold),
                )
              ],
            ),
          ),
          WLine(
            height: 0.5.px,
          ),
          child
        ],
      ),
    );
  }

  Column _orderInfo() {
    return const Column(
      children: [
        LabelItem(
          label: "车型",
          value: "远航Y7",
          labelType: LabelType.TEXT,
        ),
        LabelItem(
          label: "版本",
          value: "标准版",
          labelType: LabelType.TEXT,
        ),
        LabelItem(
          label: "外观",
          value: "白色",
          labelType: LabelType.TEXT,
        ),
        LabelItem(
          label: "内饰",
          value: "红色",
          isLast: true,
          labelType: LabelType.TEXT,
        ),
      ],
    );
  }

  Column _customerInfo() {
    return const Column(
      children: [
        LabelItem(
          label: "客户名称",
          value: "张三",
          labelType: LabelType.TEXT,
        ),
        LabelItem(
          label: "客户性别",
          value: "先生",
          labelType: LabelType.TEXT,
        ),
        LabelItem(
          label: "手机号码",
          value: "13945284862",
          labelType: LabelType.TEXT,
        ),
        LabelItem(
          label: "客户类型",
          value: "个人",
          labelType: LabelType.TEXT,
        ),
        LabelItem(
          label: "公司名称",
          value: "-",
          labelType: LabelType.TEXT,
        ),
        LabelItem(
          label: "证件类型",
          value: "身份证",
          labelType: LabelType.TEXT,
        ),
        LabelItem(
          isLast: true,
          label: "证件号码",
          value: "429006198905267458",
          labelType: LabelType.TEXT,
        ),
      ],
    );
  }

  ///车辆明细
  Column _carInfo() {
    return const Column(
      children: [
        LabelItem(
          label: "官方指导价",
          value: "290000",
          labelType: LabelType.TEXT,
        ),
        LabelItem(
          label: "抵扣价",
          value: "259000",
          labelType: LabelType.TEXT,
        ),
        LabelItem(
          label: "市场零售价",
          value: "280000",
          labelType: LabelType.TEXT,
        ),
        LabelItem(
          label: "定金金额",
          value: "50000",
          labelType: LabelType.TEXT,
        ),
        LabelItem(
          label: "尾款",
          value: "209000",
          labelType: LabelType.TEXT,
        ),
        LabelItem(
          isLast: true,
          label: "购车方式",
          value: "线上",
        ),
      ],
    );
  }

  ///其他信息
  Column _otherInfo() {
    return const Column(
      children: [
         LabelItem(
          label: "直营店",
          value: "远航汽车郑州分店",
          labelType: LabelType.TEXT,
        ),
         LabelItem(
          label: "销售顾问",
          value: "张三",
          labelType: LabelType.TEXT,
        ),
        LabelItem(
          label: "交付中心",
          value: "城市",
          labelType: LabelType.TEXT,

        ),
        LabelItem(
          labelType: LabelType.TEXT,
          value: "2024-06-11",
          label: "提车日期",

        ),
        LabelItem(
          isLast: true,
          labelType: LabelType.TEXT,
          label: "订单备注",
          value: "无",
        ),
      ],
    );
  }
}
